home *** CD-ROM | disk | FTP | other *** search
/ BMUG PD-ROM BV3 / BMUG PD-ROM Version BV3 (CDRM1097900).iso / HyperCard / XCMDs⁄XFCN / Mike's Externals / Mike's Externals / card_2290.txt < prev    next >
Text File  |  1990-02-22  |  4KB  |  114 lines

  1. -- card: 2290 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 2764
  5. -- name: 
  6.  
  7.  
  8. -- part 1 (button)
  9. -- low flags: 00
  10. -- high flags: 8001
  11. -- rect: left=236 top=65 right=83 bottom=292
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 1
  15. -- font id: 0
  16. -- text size: 12
  17. -- style flags: 0
  18. -- line height: 16
  19. -- part name: TryMe1
  20. ----- HyperTalk script -----
  21. on mousedown
  22.   set the hilite of the target to true
  23.   get the rect of the target
  24.   put item 1 of it into b
  25.   put item 4 of it into a
  26.   put bkgnd field "examples" into myField
  27.   put return&myField into myField
  28.   put FieldToMenuChoice(a,b+1,myField) into msg
  29.   set the hilite of the target to false
  30. end mousedown
  31.  
  32.  
  33.  
  34.  
  35. -- part 2 (button)
  36. -- low flags: 00
  37. -- high flags: 8001
  38. -- rect: left=304 top=65 right=83 bottom=360
  39. -- title width / last selected line: 0
  40. -- icon id / first selected line: 0 / 0
  41. -- text alignment: 1
  42. -- font id: 0
  43. -- text size: 12
  44. -- style flags: 0
  45. -- line height: 16
  46. -- part name: TryMe2
  47. ----- HyperTalk script -----
  48. on mousedown
  49.   set the hilite of the target to true
  50.   get the rect of the target
  51.   put item 1 of it into b
  52.   put item 4 of it into a
  53.   put bkgnd field "examples" into myField
  54.   put return&myField into myField
  55.   put FieldToMenuChoice(a,b+1,myField,arbitrary) into msg
  56.   set the hilite of the target to false
  57. end mousedown
  58.  
  59.  
  60.  
  61.  
  62. -- part contents for background part 17
  63. ----- text -----
  64. FieldToMenuChoice
  65.  
  66. -- part contents for background part 18
  67. ----- text -----
  68. Mike Gleason Jr.
  69.  
  70. -- part contents for background part 19
  71. ----- text -----
  72. XFCN
  73.  
  74. -- part contents for background part 20
  75. ----- text -----
  76. put FieldToMenuChoice(top,left,field [,itemName/num])
  77.  
  78.  
  79. -- part contents for background part 21
  80. ----- text -----
  81. This is the answer for those times when you need a fairly large menu, and your menustring would exceed 255 characters.  Now you can just pass a field, and this will convert each line into a menu item.  However there are a few catches:
  82. .
  83. 1: The maximum amount of items is limited to 100, and the maximum length for an item is 50 characters.  Any item over 50 will be truncated to 50 characters.
  84.  
  85. 2: There is a small bug that requires that you have an empty line in front of the list.  It won't convert the first line properly, but you can get around this by simply inserting a blank line in your field, or by concatenating a return in front of it, like this:
  86.     put Return&MyField into MyField
  87. .
  88. Now I'll explain the paramters:
  89. top, left:  The location that the popupmenu box will appear, in global screen coordinates.  An ideal place to put it is below a transparent button.  See the example's script to get an idea.
  90.  
  91. field: the field of information to convert into a menu.  Don't forget to add the extra return at the beginning!
  92.  
  93. itemName/num:  This is an optional parameter. If you don't pass anything, you'll get what you expected back, the name of the item that was selected.  If you DO pass something, you'll get back it's item number in the menu instead.
  94.  
  95. When you pass the field, note that you can add in those cryptic metacharacters to change the menu's appearance, and that you can pass more than one item on a line.  For example your field might look like this:
  96.  
  97. item one;  item two             -- passing two items on same line, separated by ;
  98. <Bitem three                        -- this will appear in BoldFace in the menu,
  99.                                                    and will appear as "item three" NOT ">Bitem three"
  100.  
  101. Likewise, you WILL NOT get ">Bitem three" back as the result, but what you really want, "item three".
  102. .
  103. One more thing, if the user pulls down the menu but doesn't select anything, a null string (or zero if you're getting the item number) will be returned, so make sure you check for that.
  104.  
  105. -- part contents for background part 23
  106. ----- text -----
  107. this is
  108. your menu
  109. so edit it
  110. <Sas you like
  111. (and
  112. -
  113. try out the
  114. <Bbuttons above